/****************************************************************************
**
** Copyright (C) 2010 Mist Poryvaev.
** All rights reserved.
** Contact: Mist Poryvaev (mist.poryvaev@gmail.com)
**
** This file is part of the SOTA project.
**
****************************************************************************/

#ifndef SOTA_H
#define SOTA_H

/*
SOTA is "(S)ignals (O)ver (T)CP/IP (A)PI"

User should use namespace "sota".
*/

// --------------------------------

#include <QtCore/QObject>
#include <QtCore/QString>

#ifdef SOTA_EXPORT
	#define SOTA_DLL __declspec(dllexport)
#elif SOTA_IMPORT
	#define SOTA_DLL __declspec(dllimport)
#else
	#define SOTA_DLL
#endif

namespace sota {

SOTA_DLL extern quint16 default_port; // default port for data exchange
SOTA_DLL extern quint32 default_signal_ttl; // default lifetime of signal in queue
SOTA_DLL extern quint32 default_max_arg_size; // default maximum buffer size for one argument in receiver

enum {
	DataStream = 0,
	Xml = 1
	  }; // flags

/*
connect/disconnect pair for sender side (that emits signals)

"receiver" format is "[ip]:[port]/[name]".
default "ip" is "127.0.0.1", default "port" is "sota::default_port", default "name" is empty
*/
SOTA_DLL bool connect(QObject * _sender, const char * _signal, const char * _receiver, const char * _slot, int _flags = DataStream);
SOTA_DLL bool disconnect(QObject * _sender, const char * _signal, const char * _receiver, const char * _slot);

/*
connect/disconnect pair for receiver side (that receives signals via slots)

"sender" format is "[ip]:[port]/[name]".
default "ip" is "127.0.0.1", default "port" is "sota::default_port", default "name" is empty
*/
SOTA_DLL bool connect(const char * _sender, const char * _signal, QObject * _receiver, const char * _slot);
SOTA_DLL bool disconnect(const char * _sender, const char * _signal, QObject * _receiver, const char * _slot);

/*
 helper function to acquire caller ip from slot
 */
SOTA_DLL QString caller_address();

}

#endif // SOTA_H
